<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			let a = " hahah ";
			console.log(a.length);
			a = 123;
			if(typeof(a) !== 'string') {
				a = a.toString();
				console.log(a.trim().length)//trim()方法只是对字符串使用
			}
			// console.log(a);
			
			let b = "这是一个电脑一个电脑一个电脑一个电脑sfdfd";
			if(b.indexOf("jsdkfjdk") !== -1) {
				console.log("有电脑两个字")
			}
			console.log(b.startsWith("这是"));
			console.log(b.endsWith("这是"));//用户判断文件后缀比较多。
			
			let c = "{name:'haha', age:20}";
			c = c.substr(1, c.length);
			console.log(c);
			c = c.substr(0, c.lastIndexOf("}"));
			console.log(c);
			//按,分隔
			let d = c.split(",");//返回数组
			console.log(d);
			console.log(d[0].split(":"));
			console.log(d[1].split(":"));
		</script>
	</body>
</html>
